<template>
	<view class="content">
		<image class="image-content" :src="good.url" mode=""></image>
		<view class="">
			<text class="small-text">商品名称：</text> <text class="good-name">{{good.name}}</text> </br>
			<text class="small-text">商品价格：</text> <text class="price">{{good.price}}💴</text> 
				<button class="card-buttons" type="default" @click="addCart(good.id)">添加购物车</button>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		onLoad: function (option) {
			this.getData(option);
					
		},
		data() {
			return {
				good: {}
			}
		},
		methods: {
			async getData (option) {
				const res = await this.$myRuquest({
					url: '/good/findById/'+option.id
				})
				this.good = res.data;
				console.log(this.good)
			},
			async addCart(id) {
				console.log(id)
				const res = await this.$myRuquest({
					url: `/shopping/addShop/`+ id
				})
				uni.showToast({
					title: '添加购物车成功'
				})
				uni.navigateTo({
					url:'../news/news?id='+id
				})
				
			}
		}
	}
</script>

<style>
.content{}
.image-content{
	width: 100%;
}
	
.card-buttons{
	position: absolute;	
	width: 100%;
	bottom: 10%;
	background-color: #ff9933;
}

.small-text{
	color: #ffcc33;
	font-size: x-large;
	font-weight: 600;
}

.good-name{
	color: #ff3366;
	font-weight: 500;
}

.price{
	color: #DD524D;
}
</style>
